import {
  Controller,
  Get,
  Post,
  UseInterceptors,
  UploadedFiles,
  Param,
} from '@nestjs/common';
import { AppService } from './app.service';

import { FilesInterceptor } from '@nestjs/platform-express';

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  getHello(): string {
    return this.appService.getHello();
  }

  @Post('/upload/:type') // 将参数 type 放在路由路径中
  @UseInterceptors(FilesInterceptor('files')) // 'files' 对应于 FormData 中的字段名
  async uploadFiles(
    @UploadedFiles() files: Array<Express.Multer.File>,
    @Param('type') type: string, // 使用 @Param() 获取路由参数
  ) {
    // 处理上传的文件
    console.log(files);
    console.log(type);

    return this.appService.uploadImage(files, type);
  }

  
}
